<include file="Public/head" />

<body>
  <form action="" id="listform">
    <div class="panel admin-panel">
      <div class="panel-head"><strong class="icon-reorder"> {:L("shangpinliebiao")}</strong></div>
      <div class="padding border-bottom">
        <ul class="search" style="padding-left:10px;">
          <li> <a class="button border-main icon-plus-square-o" href="{:U('goods/edit')}"> {:L("tianjia")}</a> </li>
          <li>{:L("sousuo")}：</li>
          <!--<li>-->
            <!--<select name="goods_cate_id" class="input" style="width:200px; line-height:17px;" onchange="changesearch()">-->
              <!--<option value="">{:L("qingxuanze")}</option>-->
              <!--<foreach name="cate_list" item="v">-->
                <!--<option value="{$v['goods_cate_id']}" <if condition="$v['goods_cate_id'] eq $goods_cate_id">selected="selected"</if>>{$v['goods_cate_name']}</option>-->
                <!--<if condition="$v['sonlist']">-->
                  <!--<foreach name="v['sonlist']" item="v2">-->
                    <!--<option value="{$v2['goods_cate_id']}" <if condition="$v2['goods_cate_id'] eq $goods_cate_id">selected="selected"</if>>-&#45;&#45;{$v2['goods_cate_name']}</option>-->
                  <!--</foreach>-->
                <!--</if>-->
              <!--</foreach>-->
            <!--</select>-->
          <!--</li>-->
          <li>
            <input type="text" placeholder="{:L('qingshuru')}{:L('shangpinmingcheng')}" name="goods_name" value="{$goods_name}" class="input" style="width:250px; line-height:17px;display:inline-block" />
            <input type="submit" value="{:L('sousuo')}" class="button border-main icon-search"/>
          </li>
        </ul>
      </div>
      <table class="table table-hover text-center">
        <tr>
          <th width="100" style="text-align:center;">{:L("xuanze")}</th>
          <th>{:L("shangpinmingcheng")}</th>
          <th>{:L("fenleibiaoti")}</th>
          <th >{:L("tupian")}</th>
          <th>{:L("xianshi")}</th>
<!--           <th>{:L("zhuye")}</th>
          <th>{:L("remen")}</th> -->
          <th >{:L("paixu")}</th>
          <th >{:L("gengxinshijian")}</th>
          <th >{:L("caozuo")}</th>
        </tr>
        <foreach name="list" item="v">
          <tr class="tr{$v['goods_id']}">
            <td style="text-align:center;">
              <input type="checkbox" name="id[]" value="{$v['goods_id']}" />
            </td>
            <td>{$v['goods_name']}</td>
            <td>{$v['goods_cate_name']}</td>
            <td><img src="__ROOT__/{$v['default_img']}" alt="" width="70" /></td>
            <td><span class="sp01" onclick="is_show({$v['goods_id']},this)">
              <if condition="$v['is_show'] == 1">
                <img src="__PUBLIC__/web/images/yes.png" width="18px;" alt="">
                <else />
                <img src="__PUBLIC__/web/images/no.png" width="18px;" alt="">
              </if>
            </span></td>
<!--             <td><span class="sp01" onclick="is_home({$v['goods_id']},this)">
              <if condition="$v['is_home'] == 1">
                <img src="__PUBLIC__/web/images/yes.png" width="18px;" alt="">
                <else />
                <img src="__PUBLIC__/web/images/no.png" width="18px;" alt="">
              </if>
            </span></td>
            <td><span class="sp01" onclick="is_hot({$v['goods_id']},this)">
              <if condition="$v['is_hot'] == 1">
                <img src="__PUBLIC__/web/images/yes.png" width="18px;" alt="">
                <else />
                <img src="__PUBLIC__/web/images/no.png" width="18px;" alt="">
              </if>
            </span></td> -->
            <td>{$v['sort']}</td>
            <td>{$v['add_time']|date="Y-m-d H:i",###}</td>
            <td>
              <div class="button-group">
                <a class="button border-main" href="{:U('goods/edit',array('id'=>$v['goods_id']))}"><span class="icon-edit"></span> {:L("bianji")}</a>
                <a class="button border-red" href="javascript:void(0)" onclick="return del({$v['goods_id']})"><span class="icon-trash-o"></span> {:L("shanchu")}</a>
              </div>
            </td>
          </tr>
        </foreach>
        <tr>
          <td colspan="10" align="left">
            <span class="maodian"></span>
            <a id="checkall" class="button border-main" href="javascript:void(0)">{:L("quanxuan")}</a>
            <a class="button border-red" href="javascript:void(0)" onclick="return DelSelect()">{:L("shanchu")}</a>
          </td>
          <td colspan="10"><div class="pagelist">{$page}</div></td>
        </tr>
      </table>
    </div>
  </form>
  <script type="text/javascript">
//单个删除
function del(id){
  if(confirm("{:L('shanchuxiaoxi')}")){
    var url = "{:U('goods/delete')}";
    $.getJSON(url,{id:id},function (data){
      if(data.result == 'tp'){$(".tr"+id).remove();}
      else if(data.result == 'break'){alert('ERROR.');}
    })
  }
}
function is_show(id,t){
  var url = "{:U('goods/is_show')}";
  $.getJSON(url,{id:id},function (data){
    if(data.result == 'yes'){
      $(t).find('img').attr('src',"__PUBLIC__/web/images/yes.png");
    }else if(data.result == 'no'){
      $(t).find('img').attr('src',"__PUBLIC__/web/images/no.png");
    }
  })
}
function is_home(id,t){
  var url = "{:U('goods/is_home')}";
  $.getJSON(url,{id:id},function (data){
    if(data.result == 'yes'){
      $(t).find('img').attr('src',"__PUBLIC__/web/images/yes.png");
    }else if(data.result == 'no'){
      $(t).find('img').attr('src',"__PUBLIC__/web/images/no.png");
    }
  })
}
function is_hot(id,t){
  var url = "{:U('goods/is_hot')}";
  $.getJSON(url,{id:id},function (data){
    if(data.result == 'yes'){
      $(t).find('img').attr('src',"__PUBLIC__/web/images/yes.png");
    }else if(data.result == 'no'){
      $(t).find('img').attr('src',"__PUBLIC__/web/images/no.png");
    }
  })
}
//全选
$("#checkall").click(function(){ 
  $("input[name='id[]']").each(function(){
   if (this.checked) {
    this.checked = false;
  }
  else {
    this.checked = true;
  }
});
})
//批量删除
function DelSelect(){
	var Checkbox=false;
  $("input[name='id[]']").each(function(){
   if (this.checked==true) {		
    Checkbox=true;	
  }
});
  if (Checkbox){
    var t=confirm("{:L('shanchuxiaoxi')}");
    if(t==false){
      return false;
    }else{
      $(".maodian").html("<input type='hidden' value='x' name='maodian' />");
      $("#listform").submit();
    }	
  }
  else{
    alert("None!");
    return false;
  }
}
</script>
</body>

</html>